package com.yuexun.dhdoctor.module.contractmanage.presenter.impl;

import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.contractmanage.bean.ContractManageInspectDetailBean;
import com.yuexun.dhdoctor.module.contractmanage.model.IContractManageModel;
import com.yuexun.dhdoctor.module.contractmanage.presenter.IContractManageInspectDetailPresenter;
import com.yuexun.dhdoctor.module.contractmanage.ui.view.IContractManageInspectDetailView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/11/23 0023.
 */

public class ContractManageInspectDetailPresenter implements IContractManageInspectDetailPresenter{
    private IContractManageInspectDetailView view;
    private IContractManageModel model;

    public ContractManageInspectDetailPresenter(IContractManageInspectDetailView view, IContractManageModel model)
    {
        this.view = view;
        this.model = model;
    }

    @Override
    public void showContractManageInspectDetail(Map<String, String> praise) {
        model.inquireCheckDetail(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<ContractManageInspectDetailBean>>() {
                               @Override
                               public void onCompleted() {

                               }

                               @Override
                               public void onError(Throwable e) {
                                   ViewInject.toast("获取数据失败:"+e.getMessage());
                               }

                               @Override
                               public void onNext(BaseEntity<ContractManageInspectDetailBean> contractManageInspectDetailBeanBaseEntity) {
                                   view.showContractManageInspectDetail(contractManageInspectDetailBeanBaseEntity);
                               }
                           }
                );
    }
}
